package com.shop.common.util;

import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description: 阿里云接口
 *
 * @author zhoulk
 * @date: 2019年04月20日  14:19
 */

public class AliyunInterface {
    /**
     * @Function com.shop.common.util.AliyunInterface.qryWuliu
     * @Description //查询物流信息
     *
     * @param: wlNo
     * @return java.lang.String
     * @errorCode //TODO
     *
     * @Author zhoulk
     * @Date 2019/4/20 14:21
     *
     **/
    public static String qryWuliu(String wlNo){
        String host = "https://wuliu.market.alicloudapi.com";
        String path = "/kdi";
        String method = "GET";
        System.out.println("请先替换成自己的AppCode");
        String appcode = "73951da6b5ca4049b1acd262d0a9cd60";  // !!!替换填写自己的AppCode 在买家中心查看
        Map<String, String> headers = new HashMap<String, String>();
        headers.put("Authorization", "APPCODE " + appcode); //格式为:Authorization:APPCODE 83359fd73fe11248385f570e3c139xxx
        Map<String, String> querys = new HashMap<String, String>();
        querys.put("no", wlNo);// !!! 请求参数
        //JDK 1.8示例代码请在这里下载：  http://code.fegine.com/Tools.zip
        try {
            HttpResponse response = HttpUtils.doGet(host, path, method, headers, querys);
            return EntityUtils.toString(response.getEntity());
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }
}
